import { getListDetail } from "@/api"

export default {
  namespaced: true,
  state: {
    detailList: {},
  },
  getters: {
    categoryView(state) {
      return state.detailList.categoryView || {}
    },
    skuInfo(state) {
      return state.detailList.skuInfo || {}
    },
    spuSaleAttrList(state) {
      return state.detailList.spuSaleAttrList || []
    },
  },
  actions: {
    async getDetail({ commit }, skuid) {
      const result = await getListDetail(skuid)
      if (result.code === 200) {
        commit("GET_DETAIL", result.data)
      } else {
        console.log(result.message)
      }
    },
  },
  mutations: {
    GET_DETAIL(state, data) {
      state.detailList = data
    },
  },
}
